package com.hbw.pinyin;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;

public class App extends Application {
    protected static App instance;
    protected Handler mainHandler;

    public static App getApp() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        mainHandler = new Handler(Looper.getMainLooper());
    }

    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
    }

    public void post(Runnable r) {
        if (r != null) {
            mainHandler.post(r);
        }
    }

    public void postDelayed(Runnable r, int delayMillis) {
        if (r != null) {
            mainHandler.postDelayed(r, delayMillis);
        }
    }

    public void removeCallbacks(Runnable r) {
        if (r != null) {
            mainHandler.removeCallbacks(r);
        }
    }
}
